﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Jermaine.Cache
{
    /// <summary>
    /// ICacheServices
    /// </summary>
    public interface ICacheService
    {
        /// <summary>
        /// 删除
        /// </summary>
        event EventHandler<CacheItemEventArgs> ItemRemoved;

        /// <summary>
        /// 添加
        /// </summary>
        event EventHandler<CacheItemEventArgs> ItemAdded;

        /// <summary>
        /// 更新
        /// </summary>
        event EventHandler<CacheItemEventArgs> ItemUpdated;

        /// <summary>
        /// 
        /// </summary>
        event EventHandler Created;

        /// <summary>
        /// 添加或者更新项
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id"></param>
        /// <param name="o"></param>
        /// <param name="expireTime"></param>
        /// <returns></returns>
        bool Put<T>(string id, T o, ExpiredTime expireTime = null);

        /// <summary>
        /// 获取项
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id"></param>
        /// <returns></returns>
        T Get<T>(string id);

        /// <summary>
        /// 删除项
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        bool Remove(string id);

        /// <summary>
        /// 删除项
        /// </summary>
        /// <param name="expireTime"></param>
        /// <returns></returns>
        bool Remove(ExpiredTime expireTime);

        /// <summary>
        /// 清空
        /// </summary>
        /// <returns></returns>
        bool Clear();

        /// <summary>
        /// 是否存在项
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        bool Exists(string id);
    }
}
